home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Resources / Developers / XAMPP 1.5.4 / Windows installer / xampp-win32-1.5.4-installer.exe / xampp / contrib / postgresql.php < prev    next >
Text File  |  2006-03-21  |  961b  |  46 lines

  1. <html>
  2. <head>
  3. <title>PHP und PostgreSQL</title>
  4. </head>
  5. <body>
  6. <h1>PHP und PostgreSQL</h1>
  7. <table border="1">
  8. <tr>
  9.     <th>Interpret</th>
  10.     <th>Titel</th>
  11.     <th>Jahr</th>
  12. </tr>
  13. <?php
  14.  
  15.     $conn_string = "host=localhost port=5432 dbname=cdcol  
  16.                     user=oswald password=geheim";
  17.  
  18.     $db_handle = pg_connect($conn_string);
  19.     if(!$db_handle)
  20.         die("Kann Datenbank nicht erreichen!");
  21.  
  22.     $query = "SELECT * FROM cds";
  23.  
  24.     $result = pg_exec($db_handle, $query);
  25.  
  26.     if (!$result) 
  27.     {
  28.         echo pg_errormessage($db_handle);
  29.     }
  30.     else
  31.     {
  32.         for ($row = 0; $row < pg_numrows($result); $row++)
  33.         {
  34.             $values = pg_fetch_array($result, $row, PGSQL_ASSOC);
  35.             echo "<tr>";
  36.             echo "<td>".$values['interpret']."</td>";
  37.             echo "<td>".$values['titel']."</td>";
  38.             echo "<td>".$values['jahr']."</td>";
  39.             echo "</tr>";
  40.         }
  41.     }
  42. ?>
  43. </table>
  44. </body>
  45. </html>
  46.